package cn.ltpcloud.admin.web.service.impl;


import cn.ltpcloud.admin.web.service.SyslogService;
import cn.ltpcloud.common.entity.AjaxResult;
import cn.ltpcloud.common.pojo.mapper.SysLogMapper;
import cn.ltpcloud.common.pojo.po.SysLog;
import cn.ltpcloud.common.utils.PageUtils;
import com.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author jiejiebiezheyang
 * @since 2024-03-12 13:00
 */
@Service
@Transactional
public class SyslogServiceImpl implements SyslogService {

    @Resource
    private SysLogMapper sysLogMapper;

    /**
     * 日志列表
     */
    @Override
    public AjaxResult list(SysLog sysLog) {
        PageUtils.startPage();
        List<SysLog> sysLogs = sysLogMapper.selectList(sysLog);
        PageInfo<SysLog> pageInfo = PageInfo.of(sysLogs);
        return AjaxResult.success(pageInfo);
    }

    /**
     * 清空日志
     */
    @Override
    public AjaxResult clean() {
        sysLogMapper.truncate();
        return AjaxResult.success();
    }
}
